<?php

/**
 * @author Martin Pernica
 * @copyright 2008
 */
if(!empty($_GET['id'])){

 $test = Registry::get('db')->query("SELECT id FROM {prefix}articles WHERE cat_id = '".intval($_GET['id'])."'");
 if((int)$test->num_rows == 0){
    $query = Registry::get('db')->query("DELETE FROM {prefix}categories WHERE id = '".intval($_GET['id'])."'");
    $log->write(8, 'com_categories', 'NOW()', 'User deleted category #' . intval($_GET['id']), $_SESSION['id']);
		Text::h1( Lang::getBack('com_categories', 'category_deleted') );
		echo '<meta http-equiv="refresh" content="2;url=index.php?p=components&name=categories">';
 }
 else{
	Text::h1( Lang::getBack('com_categories', 'category_not_empty', array($test->num_rows)) );
 }
}
?>